home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 2 / Amiga Tools 2.iso / rexx / startdviprint.rexx < prev    next >
OS/2 REXX Batch file  |  1995-03-15  |  2KB  |  79 lines

  1. /*RX
  2.  *    StartDVIprint.rexx
  3.  *
  4.  * This is a small hack to run DVIprint through ARexx, so as it may be
  5.  * called from ShowDVI or other programs.
  6. INPUTS:
  7.  * same as to dviprint, but use long option names. The last argument
  8.  * must be the name of an existing file.
  9. */
  10.  
  11. IF ~show('Libraries', 'rexxsupport.library') THEN DO
  12.    IF ~addlib('rexxsupport.library', 0, -30) THEN DO
  13.       say "Sorry, RexxSupport.library required"
  14.       EXIT 20    /* for statef() function*/
  15.    END
  16. END
  17.  
  18. /* provides
  19. stringreq("Title","initial string",StringBufSize,VisibleSize)
  20. */
  21. IF ~SHOW('L','req.library') THEN
  22.     IF ~ADDLIB('req.library',-5,-60,2) THEN DO
  23.         say "Can't open 'req.library'!"
  24.         EXIT 20
  25.         END
  26. /* ReqLib is less than ideal for what I want to do...*/
  27.  
  28. /*OPTIONS RESULTS*/
  29.  
  30. /* keep it as simple as possible, e.g. the arguments allowed are
  31. passed through to DVIprint */
  32.  
  33. PARSE ARG arguments
  34.  
  35. numargs = words(arguments)
  36.  
  37. /* last arg must be filename...*/
  38. IF word(statef(word(arguments,numargs)),1) ~= "FILE" THEN DO
  39.     name = stringreq(".dvi filename",,127,40)
  40.     IF name ~= "" THEN arguments = arguments name
  41.     ELSE EXIT
  42.     END
  43.  
  44. /* look for 'from' keyword */
  45. reqn = para("from",arguments)
  46. IF 0=reqn THEN DO
  47.     reqn = intreq("print from page ?", -100000, +100000)
  48.     IF reqn ~= "" THEN arguments = arguments" from "reqn
  49.     END
  50.  
  51. /* look for 'to' keyword */
  52. reqn = para("to",arguments)
  53. IF 0=reqn THEN DO
  54.     reqn = intreq("print upto page ?", -100000, +100000)
  55.     IF reqn ~= "" THEN arguments = arguments" to "reqn
  56.     END
  57.  
  58. say "executing: DVIprint "arguments
  59.  
  60. ADDRESS COMMAND DVIprint arguments
  61.  
  62. EXIT
  63.  
  64.  
  65. /* see if specific parameter was given*/
  66. para: PROCEDURE EXPOSE numargs
  67.  
  68. ARG name, parameters /* all switched to uppercase */
  69.  
  70. foundat = 0
  71. DO i = 1 for numargs
  72.     IF word(parameters,i) = name THEN DO
  73.         foundat = i
  74.         LEAVE
  75.         END
  76.     END
  77.  
  78. RETURN foundat
  79.